package ru.jexp.rcp.supply.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;

public abstract class ActionNewWizard extends Wizard implements INewWizard, IActionNewWizard
{
	private IAction action;
	private final String nameEditror;
	private final String idEditor;
	private final ImageDescriptor icon;

	public ActionNewWizard(String nameEditror, String idEditor, ImageDescriptor icon)
	{
		super();
		this.nameEditror = nameEditror;
		this.idEditor = idEditor;
		this.icon = icon;
	}

	@Override
	public boolean performFinish()
	{
		action.run();
		return true;
	}

	@Override
	public void init(IWorkbench workbench, IStructuredSelection selection)
	{
		init(workbench.getActiveWorkbenchWindow());
	}

	@Override
	public void init(IWorkbenchWindow window)
	{
		action = new ActionNew(window, nameEditror, idEditor, icon);
	}

	public final IAction getAction()
	{
		return action;
	}
}
